<template>
  <div class="login flex jc-c ai-c">
  </div>
</template>
<script>
  import { getUserJurisdiction } from '@/apis/user';
  import {  mapMutations } from 'vuex';
  const _config = {
    timer: null,
  }
  export default {
    data () {
      return {
        
      }
    },
    mounted(){
      this.isLogin();
    },
    methods: {
      ...mapMutations([
        'setUserInfo',
      ]),
      //判断是否登录
      isLogin(){
        this.setUserInfo({
          moduleList:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
        });
        let loc=true,firstPath="/";
        this.$router.options.routes.forEach(item=>{
          if(item.meta.navShow && loc){
            item.children.forEach(itemChild=>{
              if(this.$store.state.user.userInfo.moduleList.indexOf(itemChild.meta.moduleId)!=-1 && loc){
                //跳转,这里就是当前用户的有权限的第一个页面
                loc=false;
                firstPath=item.path+"/"+itemChild.path
              }
            })
          }
        });
        this.$router.push({ path: firstPath });
        return;
        if(this.$cookies.get("usertoken")){
          getUserJurisdiction().then(res=>{
            if(res&&res.code==200&&res.body){
              if(res.body.isManager=="1"){
                this.setUserInfo({
                  moduleList:[19,20,21,22,23]
                });
              }else{
                if(res.body.menus&&res.body.menus.length!=0){
                  this.setUserInfo({
                    moduleList:res.body.menus
                  });
                }
              }
            }
            if(res.body.isManager=="0" && res.body.menus && res.body.menus.length==0){
              //非管理员，并且menus里面为空
              //清除token,清除页面权限,跳转到菌网登录页面
              // this.$cookies.remove("usertoken");
              // this.$cookies.remove("account");
              this.setUserInfo();
              window.location.href = process.env.VUE_APP_SS_JUMP_URL;
              return;
            }
            let loc=true,firstPath="/";
            this.$router.options.routes.forEach(item=>{
              if(item.meta.navShow && loc){
                item.children.forEach(itemChild=>{
                  if(this.$store.state.user.userInfo.moduleList.indexOf(itemChild.meta.moduleId)!=-1 && loc){
                    //跳转,这里就是当前用户的有权限的第一个页面
                    loc=false;
                    firstPath=item.path+"/"+itemChild.path
                  }
                })
              }
            });
            this.$router.push({ path: firstPath });
          });
        }else{
          //清除token,清除页面权限,跳转到菌网登录页面
          this.$cookies.remove("usertoken");
          this.$cookies.remove("account");
          this.setUserInfo();
          window.location.href = process.env.VUE_APP_SS_JUMP_URL;
        }
      },
    }
  }
</script>
<style lang="scss" scoped>
  .login{
    width: 100vw;
    height: 100vh;
  }
</style>
